<?php

$connexio = new mysqli("localhost", "root", "root", "calendaridaw2");

if($connexio->connect_errno > 0) die("Error en la connexio de la BBDD [".$connexio->connect_error."]");

$rows = array();
$conn_result = $connexio->query("SELECT count(*) as total FROM usuari WHERE mail = '".$_POST["E-mail"]."' AND password = '".md5($_POST["Password"])."'");

while($rows[] = $conn_result->fetch_assoc());

$numero_total = 0;
foreach ($rows as $value) {
    if($value["total"] == '') break;
    $numero_total = $value["total"];
    //print $value["total"];
}

sleep(3);
if($numero_total == 1) print "Usuario EXISTENTE";
else print "Usuario NO EXISTENTE";

$connexio->close();

?>
